<h1 align="center"><strong>申请结果</strong></h1>
<h2 align="center">
    <?php
    include_once "../model/model.php";
    include_once "../model/pile.php";
    if (isset($_POST["name"]) && $_POST["name"] != "" && $_POST["year"] != "" && $_POST["month"] != "" && $_POST["day"] != "" && $_POST["start"] != "" && $_POST['end'] != '' && $_POST['place'] != '') {
		$pattern = "/0([1-9])/";
		$replacement = "$1";
		$_POST["month"] = preg_replace($pattern, $replacement, $_POST["month"]);
        if (is_numeric($_POST["month"]) && is_numeric($_POST["year"]) && is_numeric($_POST["day"])) {
            if (checkdate($_POST["month"], $_POST["day"], $_POST["year"])) {
                $date = $_POST["year"] . "-" . $_POST["month"] . "-" . $_POST["day"];
                if (strtotime($date) > strtotime(date("Y-n-j")) && $_POST["start"] <= $_POST['end']) {
                    $meeting_request = new MEETING();
                    $requestofroom = $meeting_request->check($_POST["name"], $date, $_POST["start"], $_POST['end'], $_POST['place'], $_POST["detail"]);
                    switch ($requestofroom) {
                        case MEETING::waitting:
                            echo "申请已记录，等待管理员审核……";
                            break;
                        case MEETING::refuse:
                            echo "您已被添加至黑名单，不具有申请资格！";
                            break;

                        case MEETING::submitted:
                            echo "您已经提交申请！";
                            break;

                        case MEETING::full:
                            echo "会议室已被占用！";
                            break;
                        default:
                            echo "something is wrong!";
                            break;
                    }
                } else {
                    echo "无效的申请时间！";
                }
            } else {
                echo "请检查日期！";
            }
        } else {
            echo "日期格式不正确！";
        }
    } else {
        echo "请填写完整信息！";
    }
    ?>
    <a href="../user/form3.php">返回</a>
</h2>
